package cn.echo.consul.manager.exception;

import cn.echo.consul.manager.response.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

import static cn.echo.consul.manager.response.ResultCode.F11400;

/**
 * 内部服务异常
 * @author lonyee
 *
 */
@Data
@EqualsAndHashCode(callSuper=false)
public class InnerServerException extends RuntimeException {

	private static final long serialVersionUID = -3558232926509169927L;

	private Integer code;
	private String msg;

    public InnerServerException(Integer code, String msg, Object... args) {
        super(String.format(msg, args));
        this.code = code;
        this.msg = String.format(msg, args);
    }

    public InnerServerException(ResultCode resultCode, Object... args) {
        this(resultCode.getCode(), resultCode.getMsg(), args);
    }

    public InnerServerException(String msg) {
        this(F11400.getCode(), msg);
    }
}
